<?php
/**
 * 视频控制器
 * Created		: 2012-10-08
 * Modified		: 2012-10-08
 * @link		: http://www.dota100.com
 * @copyright	: (C) 2012 dota100.com 
 * @author		: Joseph Chen (chenliq@gmail.com)
 */
class Controller_Video extends Controller
{
	/**
	 * 视频表
	 * @var string
	 */
	public $tbl = 'videos';
	
	/**
	 * 控制器载入后执行
	 */
	public function initialize()
	{
	}
	
	/**
	 * 视频列表
	 * @see Controller::index()
	 */
	public function index() 
	{
		// 视频列表
		$mo = new Model_Video();
		$params = array(
			'order'	=> 'post_time desc',
			'limit'	=> 30,
		);
		$videoList = $mo->getList();
	}
	
	/**
	 * 视频播放页
	 */
	public function view()
	{
		if (empty($_GET['id']) || !ctype_digit($_GET['id']))
		{
			$this->display('view404');
		}

		$mo = new Model_Video();
		$this->detail = $mo->read($_GET['id']);
	}
	
	/**
	 * 获取视频列表
	 */
	public function getVideoList() 
	{
		// 获取视频列表
		switch ($_GET['order'])
		{
			// 根据浏览器排序
			case 'hot':
				$order = 'views desc';
			break;
					
			// 根据生命值排序
			case 'hp':
				$order = 'hp desc';
			break;
			
			// 根据评分排序
			case 'score':
				$order = 'score desc';
			break;
			
			// 默认时间排序
			case 'latest':
			default:
				$order = 'post_time desc';
			break;
		}
		
		$mo = new Model_Video();
		$params = array(
			'order'	=> 'post_time desc',
			'limit'	=> 30,
		);
		$videoList = $mo->getList();
		$this->json('', 1, $videoList);
	}
	
}